import React from "react";
import {inject, observer} from "mobx-react";
import {withRouter} from "react-router-dom";
import {WrOrg} from "../../../public";

/**
 * 考核报表-下属方案或组织部门
 * jiansong 2019/11/8
 */
@inject("reportStore")
@withRouter
@observer
export default class Org extends React.Component {

    constructor(props) {
        super(props);
        this.store = this.props.reportStore;
    }

    render() {
        const {orgStore,onSearchChange,setState,getTableDatas} = this.store;
        return (
            <WrOrg
                orgStore={orgStore}
                type={this.props.type}
                onSelect={(id, data, type) => {
                    if (this.props.type == "org") {
                        if (type == 1) {
                            onSearchChange({"hrmids": "", "subcompanyids": id, "departmentids": ""});
                            setState({subBrowserValue: data, deptBrowserValue: [], hrmBrowserValue: []})
                        } else if (type == 2) {
                            onSearchChange({"hrmids": "", "subcompanyids": "", "departmentids": id});
                            setState({subBrowserValue: [], deptBrowserValue: data, hrmBrowserValue: []})
                        } else if (type == 3) {
                            onSearchChange({"hrmids": id, "subcompanyids": "", "departmentids": ""});
                            setState({subBrowserValue: [], deptBrowserValue: [], hrmBrowserValue: data})
                        }
                    } else {
                        onSearchChange({"hrmids": id, "subcompanyids": "", "departmentids": ""});
                        setState({hrmBrowserValue: data})
                    }
                    getTableDatas(false);
                    this.store.showtype = "detail";
                }}
            />
        )
    }

}